<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>dom-offset &lsaquo; KISSY Docs</title>
<link rel="stylesheet" href="../assets/base-min.css" />
<link rel="stylesheet" href="../assets/docs.css" />
</head>
<body class="w866">
<div id="header">
    <a class="logo" href="../index.html"><img src="../assets/logo.png" alt="KISSY" width="138" height="74" /></a>
    <p class="rel-nav">
        <a href="http://github.com/kissyteam/kissy/blob/master/src/dom/dom-offset.js"><code>dom-offset.js</code></a>
    </p>
</div>
<div id="content" class="layout grid-s232m0">
    <div class="col-main">
        <div class="main-wrap">

            <div class="section">
                <h3 id="methods">Methods</h3>

                <div class="member method">
                    <h4>
                        <a name="method_offset">offset</a>
                        <code>Object <em>offset</em> ( selector )</code>
                    </h4>
                    <div class="detail">
                        <p>获取符合选择器的第一个元素的相对 page 的 offset 值。</p>
                        <p></p>
                    </div>
                    <h4>
                        <code>void <em>offset</em> ( selector, value )</code>
                    </h4>
                    <div class="detail">
                        <p>给符合选择器的所有元素设置 offset 值。</p>
                        <p class="tips">设置 offset 时，需要保证所设置的元素在布局流中（非 display: none 等脱离布局流的元素），否则设置的值有可能不对。</p>
                    </div>
                    <pre class="example-code"><code>
var S = KISSY, DOM = S.DOM;

// 获取 offset:
DOM.offset('#id'); // 返回 { left: 10, top: 20 }

// 设置 offset:
DOM.offset('#id', { left: 10, top: 20 });
</code></pre>
                </div>

                <div class="member method">
                    <h4>
                        <a name="method_scrollLeft">scrollLeft</a>
                        <code>Number <em>scrollLeft</em> ( )</code>
                    </h4>
                    <div class="detail">
                        <p>获取 document 的 scrollLeft 值。</p>
                    </div>
                </div>

                <div class="member method">
                    <h4>
                        <a name="method_scrollTop">scrollTop</a>
                        <code>Number <em>scrollTop</em> ( )</code>
                    </h4>
                    <div class="detail">
                        <p>获取 document 的 scrollTop 值。</p>
                    </div>
                </div>

                <div class="member method">
                    <h4>
                        <a name="method_docHeight">docHeight</a>
                        <code>Number <em>docHeight</em> ( )</code>
                    </h4>
                    <div class="detail">
                        <p>获取 document 的 height 值。</p>
                    </div>
                </div>

                <div class="member method">
                    <h4>
                        <a name="method_docWidth">docWidth</a>
                        <code>Number <em>docWidth</em> ( )</code>
                    </h4>
                    <div class="detail">
                        <p>获取 document 的 width 值。</p>
                    </div>
                </div>

                <div class="member method">
                    <h4>
                        <a name="method_viewportHeight">viewportHeight</a>
                        <code>Number <em>viewportHeight</em> ( )</code>
                    </h4>
                    <div class="detail">
                        <p>获取当前 viewport 的 height 值。</p>
                    </div>
                </div>

                <div class="member method">
                    <h4>
                        <a name="method_viewportWidth">viewportWidth</a>
                        <code>Number <em>viewportWidth</em> ( )</code>
                    </h4>
                    <div class="detail">
                        <p>获取当前 viewport 的 width 值。</p>
                    </div>
                </div>

                <div class="member method">
                    <h4>
                        <a name="method_scrollIntoView">scrollIntoView</a>
                        <code>void <em>scrollIntoView</em> ( )</code>
                    </h4>
                    <div class="detail">
                        <p>让容器中的任一元素滚动到该容器的视窗显示部分。</p>
                    </div>
                </div>

            </div>

            <div class="section">
                <h3>Examples</h3>
                <p>测试页面：<a href="http://kissyteam.github.com/kissy/src/dom/test-dom-offset.html"><code>test-dom-offset.html</code></a></p>

                <div class="section notes">
                    <p>dom-offset 提供的所有方法：</p>
                    <ol>
                        <li>setter 和 getter 都遵循 get first, set all 原则：如果是获取，仅获取符合选择器的第一个元素的值；如果是设置，则操作符合选择器的所有元素。</li>
                    </ol>
                </div>
            </div>

        </div>
    </div>
    <div class="col-sub">
        <div class="sub-wrap">
            <div class="loc">
                <a href="../index.html">home</a> &rsaquo;
                <a href="index.html">dom</a> &rsaquo;
                dom-offset :
            </div>
            <div class="toc">
                <h3>Methods</h3>
                <ul>
                    <li><a href="#method_offset">offset</a></li>
                    <li><a href="#method_scrollLeft">scrollLeft</a></li>
                    <li><a href="#method_scrollTop">scrollTop</a></li>
                    <li><a href="#method_docHeight">docHeight</a></li>
                    <li><a href="#method_docWidth">docWidth</a></li>
                    <li><a href="#method_viewportHeight">viewportHeight</a></li>
                    <li><a href="#method_viewportWidth">viewportWidth</a></li>
                    <li><a href="#method_scrollIntoView">scrollIntoView</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>
<div id="footer">
    <p class="copyright">&copy; 2009 - 2029 KISSY UI LIBRARY</p>
</div>
</body>
</html>
